package com.lmh.common;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @program code
 * @Description 统一配置参数
 * @Author limeihua
 * @Date 2024/08/01 11:16
 * @Version 1.0
 */
public class Constants {
    public static String CLICKHOUSE_URL;
    public static String CLICKHOUSE_USERNAME;
    public static int CLICKHOUSE_INITIALSIZE;
    public static int CLICKHOUSE_MINIDLE;
    public static int CLICKHOUSE_MAXACTIVE;
    public static int CLICKHOUSE_MAXWAIT;
    public static int CLICKHOUSE_TIMEBETWEENEVICTIONRUNSMILLIS;
    public static String HIVE_URL;
    public static String HIVE_USERNAME;
    public static int HIVE_INITIALSIZE;
    public static int HIVE_MINIDLE;
    public static int HIVE_MAXACTIVE;
    public static int HIVE_MAXWAIT;
    public static int HIVE_TIMEBETWEENEVICTIONRUNSMILLIS;
    public static String REDIS_HOST;
    public static int REDIS_PORT;
    public static int REDIS_TIMEOUT;
    

    static {
        Properties props = new Properties();
        InputStream in = null;
        try {
            in = Constants.class.getClassLoader().getResourceAsStream("config.properties");
            props.load(in);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        CLICKHOUSE_URL = props.getProperty("clickhouse_Url");
        CLICKHOUSE_USERNAME = props.getProperty("clickhouse_Username");
        CLICKHOUSE_INITIALSIZE = Integer.parseInt(props.getProperty("clickhouse_InitialSize"));
        CLICKHOUSE_MINIDLE = Integer.parseInt(props.getProperty("clickhouse_MinIdle"));
        CLICKHOUSE_MAXACTIVE = Integer.parseInt(props.getProperty("clickhouse_MaxActive"));
        CLICKHOUSE_MAXWAIT = Integer.parseInt(props.getProperty("clickhouse_MaxWait"));
        CLICKHOUSE_TIMEBETWEENEVICTIONRUNSMILLIS = Integer.parseInt(props.getProperty("clickhouse_TimeBetweenEvictionRunsMillis"));

        HIVE_URL = props.getProperty("hive_Url");
        HIVE_USERNAME = props.getProperty("hive_Username");
        HIVE_INITIALSIZE = Integer.parseInt(props.getProperty("hive_InitialSize"));
        HIVE_MINIDLE = Integer.parseInt(props.getProperty("hive_MinIdle"));
        HIVE_MAXACTIVE = Integer.parseInt(props.getProperty("hive_MaxActive"));
        HIVE_MAXWAIT = Integer.parseInt(props.getProperty("hive_MaxWait"));
        HIVE_TIMEBETWEENEVICTIONRUNSMILLIS = Integer.parseInt(props.getProperty("hive_TimeBetweenEvictionRunsMillis"));
        
        REDIS_HOST = props.getProperty("redis_host");
        REDIS_PORT = Integer.parseInt(props.getProperty("redis_port"));
        REDIS_TIMEOUT = Integer.parseInt(props.getProperty("redis_timeout"));
    }

    private Constants() {

    }
}
